const initialState = {
	loading: true,
	error: false,
	articleList: []
}

const LOAD_ARTICLES = "load_articles";
const LOAD_ARTICLES_SUCCESS = "load_articles_success";
const LOAD_ARTICLES_ERROR = "load_articles_error";

export default function previewList(state=initialState, action) {
	switch(action.type) {
		case LOAD_ARTICLES:
			return {
				...state,
				loading: true,
				error: false
			}
		case LOAD_ARTICLES_SUCCESS:
			return {
				...state,
				loading: false,
				error: false,
				articleList: action.payload
			}
		case LOAD_ARTICLES_ERROR:
			return {
				...state,
				loading: false,
				error: true
			}
		default:
			return state;
	}
}